﻿#include "dbutil.h"
#include <QtSql>
#include <string>
#include <iostream>
using namespace std;

Dbutil::Dbutil(QObject *parent) :
    QObject(parent){}

QSqlDatabase Dbutil::connect(void){
    QSqlDatabase db;
    if(QSqlDatabase::contains("qt_sql_default_connection"))
      db = QSqlDatabase::database("qt_sql_default_connection");
    else
      db = QSqlDatabase::addDatabase("QMYSQL");
    //QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("pas-das");
    db.setUserName("root");
    db.setPassword("");
    db.open();
    return db;
}

void Dbutil::dbclose(QSqlDatabase db){
    //if(db.close()) qDebug()<<"ddd";
    db.close();
}

